﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using ModelLayer;
using Client.Service;


namespace Client
{
    public partial class ShowTypesGUI : Form
    {
        private IShow showService;
        private ICities cityService;
        
        public ShowTypesGUI()
        {
            InitializeComponent();
            showService = new ShowClient("BasicHttpBinding_IShow");
            cityService = new CitiesClient("BasicHttpBinding_ICities");
            
        }


        private void button1_Click(object sender, EventArgs e)
        {
            
            //broken
            int showId = Convert.ToInt32(comboBox1.Text);
            Show show = showService.GetShow(showId);


            pictureBox1.ImageLocation = show.ImageDir;


        }

        private void button3_Click(object sender, EventArgs e)
        {
            //string sdate = comboBox1.Text;
            //DateTime date = DateTime.Parse(sdate);
            //List<Show> list = showCtr.getShowsByDate(date);
           
            //foreach (Show s in list)
            //{  
            //    imageList2.Images.Add(LoadImage(s.ImageDir));
            //    listView1.Items.Add(s.Type.Title, 0);
            //    listView1.Items.Add(s.Type.Title, 4); 
            //}
        }

        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void button7_Click(object sender, EventArgs e)
        {
            ShowType st = null;
            City city = null;

            city = cityService.RetrieveCity(9000);
            st = showService.GetTypeOnShowId(1);
            //bruger showService
            ListViewItem item1 = new ListViewItem(st.Title);
            listView1.Items.Add(item1);
            item1.SubItems.Add(st.Description);

            //bruger cityService
            //ListViewItem item2 = new ListViewItem(city.CityName);
            item1.SubItems.Add(city.CityName);
            //listView1.Items.Add(item2);

            //Test om der kan vises billeder (spoiler alert: det kan der)
            Show show = showService.GetShow(1);



            pictureBox1.ImageLocation = show.ImageDir;
            
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        //private Image LoadImage(string url)
        //{
        //    //System.Net.WebRequest request =
        //    //    System.Net.WebRequest.Create(url);

        //    //System.Net.WebResponse response = request.GetResponse();
        //    //System.IO.Stream responseStream =
        //    //    response.GetResponseStream();

        //    //Bitmap bmp = new Bitmap(responseStream);

        //    //responseStream.Dispose();

        //    //return bmp;
        //}
    }
}
